package bb.lanxing.lib.devices.antplus;

import android.content.Context;
import com.dsi.ant.plugins.antplus.pcc.AntPlusHeartRatePcc;
import com.dsi.ant.plugins.antplus.pcc.defines.EventFlag;
import com.dsi.ant.plugins.antplus.pccbase.PccReleaseHandle;
import bb.lanxing.lib.devices.api.SmartDevice;
import bb.lanxing.lib.devices.core.provider.DataNotifier;
import java.math.BigDecimal;
import java.util.EnumSet;

public class AntPlusHearRate extends AbsAntPlusDevice<AntPlusHeartRatePcc>
        implements AntPlusHeartRatePcc.IHeartRateDataReceiver {
    @Override
    public String getCurrentFileNameInTransfer() {
        return "";
    }

    public AntPlusHearRate(Context context, SmartDevice smartDevice) {
        super(context, smartDevice);
    }

    @Override
    protected PccReleaseHandle<AntPlusHeartRatePcc> requestAccessToPPC() {
        return AntPlusHeartRatePcc.requestAccess(this.mAppContext, getDeviceNumber(), 0, this, this);
    }

    @Override
    public void subscribeEvents(AntPlusHeartRatePcc antPlusHeartRatePcc) {
        antPlusHeartRatePcc.subscribeHeartRateDataEvent(this);
    }

    @Override
    public void unsubscribeEvents(AntPlusHeartRatePcc antPlusHeartRatePcc) {
        if (antPlusHeartRatePcc != null) {
            antPlusHeartRatePcc.subscribeHeartRateDataEvent(null);
        }
    }

    @Override
    public void onNewHeartRateData(long j, EnumSet<EventFlag> enumSet, int i, long j2, BigDecimal bigDecimal, AntPlusHeartRatePcc.DataState dataState) {
        d("HeartRate: " + i);
        DataNotifier.notifyHeartrateData(getType(), getAddress(), i);
        AntPlusDataDispatcher.getInstance().notifyHeartrateData(i);
    }
}
